//
//  GMReadPdfView.m
//  Teecloud
//
//  Created by 小熊 on 2018/12/7.
//  Copyright © 2018年 小志. All rights reserved.
//

#import "GMReadPdfView.h"
@interface GMReadPdfView()
/**播放数*/
@property (weak, nonatomic) IBOutlet UILabel *playCount;
/**习题数*/
@property (weak, nonatomic) IBOutlet UILabel *etrat;
/**附件数*/
@property (weak, nonatomic) IBOutlet UILabel *fujian;
/* 上一次选择的按钮 */
@property (weak , nonatomic)UIButton *lastSelectButton;
@property (weak, nonatomic) IBOutlet UIView *viewq;
@property (weak, nonatomic) IBOutlet UIView *vieww;

@end
/** 按钮tag附加值 */
#define BTNTAG 1000;
@implementation GMReadPdfView

-(void)awakeFromNib{
    [super awakeFromNib];
    //点击手势
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doTapChange1:)];
    [self.viewq addGestureRecognizer:tap1];
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doTapChange2:)];
    [self.vieww addGestureRecognizer:tap2];
}
-(void)setModel:(GMCommentBaseModel *)model{
    _model = model;
    self.playCount.text = [NSString stringWithFormat:@"%@",model.PlayCount];
    self.etrat.text =[NSString stringWithFormat:@"%@/%@",model.ExerCount,model.Count];
    self.fujian.text =[NSString stringWithFormat:@"%ld",model.AttachList.count?model.AttachList.count:0];
    if ([model.Count isEqualToNumber:@(0)]) {
        self.etrat.textColor = kDarkGrayColor;
    }else{
        self.etrat.textColor = [UIColor colorWithHexString:@"007AFF"];
    }
    if (model.AttachList.count ==0) {
        self.fujian.textColor = kDarkGrayColor;
    }else{
        self.fujian.textColor = [UIColor colorWithHexString:@"007AFF"];
    }
}

//习题点击
-(void)doTapChange1:(UITapGestureRecognizer *)sender{
    if (![self.model.Count isEqualToNumber:@(0)]) {
        self.tapBlock(0);
    }
}
//附件点击
-(void)doTapChange2:(UITapGestureRecognizer *)sender{
    if (self.model.AttachList.count >0) {
        self.tapBlock(1);
    }
}
/**按钮点击*/
- (IBAction)selectBtn:(UIButton *)sender {
     NSInteger buttonTag = sender.tag - BTNTAG;
    switch (buttonTag) {
        case 0:{
          self.tapBlock(2);
        }
            break;
        case 1:{
            self.tapBlock(3);
        }
            break;
        case 2:{
            self.tapBlock(4);
        }
            break;
        case 3:{
            self.tapBlock(5);
        }
            break;
        default:
            break;
    }
}
@end
